package com.example.ktpspringboot.controller;

import com.example.ktpspringboot.service.impl.FileServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;


@RestController
public class FileController {

    @Autowired
    private FileServiceImpl fileServiceImpl;

    @RequestMapping("/commitFile")
    public String commitFile(@RequestPart("homeworkId") String homeworkId, @RequestPart("file") MultipartFile file) {
        try {
            return fileServiceImpl.upload(file,homeworkId);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }
}
